{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn import datasets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "boston = datasets.load_boston()\n",
    "X = boston.data\n",
    "y = boston.target\n",
    "\n",
    "X = X[y < 50]\n",
    "y = y[y < 50]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from model_selection import my_train_test_split\n",
    "X_train, X_test, y_train, y_test = my_train_test_split(X, y, random_state=666)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "from LinearRegression import LinearRegression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "LinearRegression()"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reg  = LinearRegression()\n",
    "reg.fit_normal(X_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ -1.18919477e-01,   3.63991462e-02,  -3.56494193e-02,\n",
       "         5.66737830e-02,  -1.16195486e+01,   3.42022185e+00,\n",
       "        -2.31470282e-02,  -1.19509560e+00,   2.59339091e-01,\n",
       "        -1.40112724e-02,  -8.36521175e-01,   7.92283639e-03,\n",
       "        -3.81966137e-01])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reg.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "34.161435496217081"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reg.interception_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 18.08047724,  25.52374702,  12.93068154,  32.89616169,\n",
       "        24.17956679,   2.67010028,  26.64700396,  32.23851244,\n",
       "        13.96168643,  24.04280799,  14.93247906,  10.58513734,\n",
       "        30.28710828,  16.2782111 ,  23.67817017,  25.64047759,\n",
       "        18.67821777,  24.02076592,  28.77437534,  26.93946254,\n",
       "        12.81354434,  27.22770353,  26.0804716 ,  23.41900039,\n",
       "        20.79727917,  31.96786535,  14.90862058,  20.954883  ,\n",
       "        12.92314457,  29.80207127,  35.28684545,   5.03624207,\n",
       "        13.10143242,  35.54317123,  15.98890703,  21.53597166,\n",
       "        12.47621364,  29.12864349,  27.36022467,  24.05031901,\n",
       "        14.35220626,  23.61433371,  10.90347719,  22.38154099,\n",
       "        18.62937294,  16.37126778,  24.43078261,  33.06293684,\n",
       "        19.19809767,  27.04404675,  18.05674457,  14.85136715,\n",
       "        25.08935314,  16.0884098 ,  21.74619772,  16.3194766 ,\n",
       "        24.25591698,  11.72935395,  27.92260116,  31.05867941,\n",
       "        20.17444189,  24.9964365 ,  25.99734127,  12.14007801,\n",
       "        16.58246637,  27.30690012,  22.26787948,  21.72492458,\n",
       "        31.50402544,  14.03991351,  16.42672344,  24.77534313,\n",
       "        25.18133042,  18.65228238,  17.34412768,  27.90749795,\n",
       "        23.71553798,  14.62906156,  11.22231617,  31.4243847 ,\n",
       "        33.66552044,  17.66375929,  18.69989012,  17.79423031,\n",
       "        25.15668084,  23.66633124,  24.55578753,  26.09123112,\n",
       "        25.49718056,  20.28898727,  24.87506605,  33.48356492,\n",
       "        36.08610386,  23.07558528,  18.79472835,  31.04138456,\n",
       "        35.78577626,  20.84603282])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reg.predict(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.81298026026584924"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reg.score(X_test, y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
